<?php
namespace app\home\controller;
use think\Db;
use think\captcha\Captcha;
use think\Loader;
class Disi extends \think\Controller{
    public function disi(){
        if(isset($_POST['up'])){
            $content=input('param.content','','htmlspecialchars');
            $ret=db('article')->where('title|author','like',"%$content%")->select();


            $data=array();
            foreach($ret as $val){
                $img=json_decode($val['img'],true);
                if($img!=NULL){
                    $val['img']=$img;
                }
                $data[]=$val;
            }
            $this->assign('ret',$data);
        }
        else{
            $ret=db('article')->select();
            $data=array();
            foreach($ret as $val){
                $img=json_decode($val['img'],true);
                if($img!=NULL){
                    $val['img']=$img;
                }
                $data[]=$val;
            }
            $this->assign('ret',$data);
            // return $this->fetch('dier');
        }
        
        return $this->fetch('disi');//继承基类的控制器 
    }
    
}